package com.apex.wx.service.impl;

import com.apex.common.controller.BaseService;
import com.apex.security.api.entity.Pager;
import com.apex.security.api.entity.VBsdtDb;
import com.apex.security.api.entity.VBsdtDbSummary;
import com.apex.security.api.entity.VBsdtYb;
import com.apex.wx.domain.MessageApproveRepository;
import com.apex.wx.domain.WorkflowRepository;
import com.apex.wx.service.ScheduleCenterService;
import com.jsoniter.output.JsonStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-4-8
 */
@Service
public class ScheduleCenterServiceImpl extends BaseService implements ScheduleCenterService {

    @Autowired
    private WorkflowRepository repository;

    @Autowired
    private MessageApproveRepository messageApproveRepository;

    @Override
    public void index(ModelMap modelMap, String userID) {

    }

    @Override
    public void wxIndex(ModelMap modelMap, String userId) {
        VBsdtDbSummary vBsdtDbSummary = getObject(VBsdtDbSummary.class, repository.getUserDbSummary(userId));
        modelMap.put("db_summary", vBsdtDbSummary);
    }

    @Override
    public void userAllDb(ModelMap modelMap, String userID, String title, Pager pager) {

    }

    @Override
    public void userAllYb(ModelMap modelMap, String userID, String title, Pager pager) {

    }

    @Override
    public void userAllDispatch(ModelMap modelMap, String userID, String title, Pager pager) {

    }

    @Override
    public void userAllDispatch(ModelMap modelMap, Pager pager) {

    }

    @Override
    public void userDispatch(ModelMap modelMap, String userID, Long id) {

    }

    @Override
    public void userDispatch(ModelMap modelMap, Long id) {

    }

    @Override
    public void userAllLecture(ModelMap modelMap, String userId, String title, Pager pager) {

    }

    @Override
    public void userLecture(ModelMap modelMap, String userID, Long id) {

    }

    @Override
    public void userAllApplication(String userId, ModelMap modelMap, String title, Pager pager, boolean normal) {

    }

    @Override
    public String userAllApplication(String userid, String title, int content) {
        return null;
    }

    @Override
    public String userSummary(String userid) {
        return null;
    }

    /**
     * 通知公告
     * @return
     */
    @Override
    public String allNotice() {

        return null;
    }

    @Override
    public String userAllLecture(String userId, Pager pager, String title, int content) {
        return null;
    }

    @Override
    public String userAllDb(String userID, String title, int content) {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("userID", userID);
        Pager pager = new Pager();
        if(!StringUtils.isEmpty(title)){
            map1.put("title",title);
        }
        if(content>0){
            pager.setCurrent(content);
            pager.setRows(11);
        }else {
            pager.setCurrent(1);
            pager.setRows(6);
        }
        map1.put("pager", pager);
        List<VBsdtDb> list_db = getAllListObject(VBsdtDb.class, repository.getAllPageDB(JsonStream.serialize(map1)));//用户待办
        Map<String, Object> map = new HashMap<>();
        map.put("dataList", list_db);
        return JsonStream.serialize(map);
    }

    @Override
    public String userAllYb(String userID, String title, int content) {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("userID", userID);
        Pager pager = new Pager();
        if(!StringUtils.isEmpty(title)){
            map1.put("title",title);
        }
        if(content>0){
            pager.setCurrent(content);
            pager.setRows(11);
        }else {
            pager.setCurrent(1);
            pager.setRows(6);
        }
        map1.put("pager", pager);
        List<VBsdtYb> list_yb = getAllListObject(VBsdtYb.class, repository.getAllPageYB(JsonStream.serialize(map1)));
        Map<String, Object> map = new HashMap<>();
        map.put("dataList", list_yb);
        return JsonStream.serialize(map);
    }

    @Override
    public String userDispatch(String userID, String title, int content) {
        return null;
    }

    @Override
    public void books(String userId, ModelMap modelMap) {

    }

    @Override
    public void miscellaneous(String userId, ModelMap modelMap) {

    }

    @Override
    public void assets(ModelMap modelMap, String userId, Pager pager) {

    }

    @Override
    public void newsEntity(HttpServletRequest request, ModelMap modelMap, String userId) {

    }
}
